;;;; This file contains functions to use in the
;;;;    configuration files.

(defun rc/create-tmp-dirs (parent-dir)
  (progn
    (unless (file-exists-p parent-dir) (make-directory parent-dir))
    (unless (file-exists-p auto-save-list-file-prefix) (make-directory auto-save-list-file-prefix))
    (unless (file-exists-p (cadar lock-file-name-transforms)) (make-directory (cadar lock-file-name-transforms)))))

;;; rc/require package manager made by Tsoding <reximkut@gmail.com>
;;;     Original code in https://github.com/rexim/dotfiles/blob/master/.emacs.rc/rc.el

(defvar rc/package-contents-refreshed nil)

(defun rc/package-refresh-contents-once ()
  (when (not rc/package-contents-refreshed)
    (setq rc/package-contents-refreshed t)
    (package-refresh-contents)))

(defun rc/require (&rest packages)
  (dolist (package packages)
    (when (not (package-installed-p package))
      (rc/package-refresh-contents-once)
      (package-install package))))
